package com.ly.juc.problem;
import	java.util.concurrent.locks.ReentrantLock;
import java.time.Duration;
import	java.time.Instant;



import java.time.Instant;
import java.util.HashMap;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.StampedLock;

/**
 * @Classname Problem3
 * @Description
 * 用阻塞队列实现生产者消费者模式
 * @Date 2020/11/18 16:54
 * @Author 冷心影翼
 */
public class Problem3 {

	ArrayBlockingQueue<String> arrayBlockingQueue = new ArrayBlockingQueue<>(10);



	public void T1() {
		new Thread(()->{
			for(int i=0;i<10;i++) {
				try {
					arrayBlockingQueue.put(i+"");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}).start();

		new Thread(()->{
			for(int i=0;i<10;i++) {
				String poll = arrayBlockingQueue.poll();
				System.out.println(poll);

			}
		}).start();


	}




}
